/**
 * @author htqw
 * @param {import("mysql2").Connection} connection
 * @param {string} table
 * @param {string[]} columns
 * @param {string | undefined} where
 */
export default async function selectTableData(connection, table, columns, where) {
    return new Promise((resolve, reject) => {
        connection.query(`SELECT ${columns.join(',')} FROM ${table} ${where?`WHERE ${where}`:''}`, (err, result) => {
            if (err) reject(err)
            resolve(result)
        })
    })
}